package com.djhu.freepartner.web.control;

import com.djhu.freepartner.core.RestRsp;
import com.djhu.freepartner.core.Status;
import com.djhu.freepartner.web.control.model.FavouriteModel;
import com.djhu.freepartner.web.service.IFavouriteService;
import com.google.gson.Gson;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/favourite")
@Slf4j
public class FavouriteControl {


    @Autowired
    private IFavouriteService favouriteService;

    @Autowired
    private Gson gson;

    @ApiOperation("将帖子增加到关注列表")
    @PostMapping("/post/add")
    public RestRsp watchpost(@RequestBody FavouriteModel favouriteModel){
        log.info("watchpost receive request ,request is {}",gson.toJson(favouriteModel));
        favouriteService.watch(favouriteModel);
        RestRsp restRsp = new RestRsp(Status.SUCCESS);
        return restRsp;
    }

    @ApiOperation("取消关注")
    @PostMapping("/post/del")
    public RestRsp unwatchpost(@RequestBody FavouriteModel favouriteModel){
        return null;
    }

    @ApiOperation("获取所有的关注列表")
    @PostMapping("/post/list")
    public RestRsp list(@RequestBody FavouriteModel favouriteModel){
        return null;
    }


}
